<!-- 生产工作安排(无票) gzrwd.jsp -->
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/jsp/common/common.jsp"%>
<html>
	<head>
		<script type="text/javascript" src="<%=contextPath%>/js/jquery.autogrow.js"></script> 
		<script type="text/javascript" src="<%=contextPath%>/js/validator.js"></script> 
		<script type="text/javascript" src="<%=contextPath%>/js/My97DatePicker/WdatePicker.js"></script>
		
		<script type="text/javascript" language="javascript">  
		// 人行号
			var usernum = 1;
			<c:if test="${listRwd != null || fn:length(listRwd) != 0 }">
				usernum = ${fn:length(listRwd)};
				usernum=usernum+1;
			</c:if>
			
			var bz = '<c:out value="${bz}"/>';
		
		$(document).ready (function() {
			
			$('textarea').autogrow();		
		});
		
			Ext.onReady(function(){
				var tb = new Ext.Toolbar({
			   		renderTo: document.all.tbar,
			    	items: [
						{
				            text: '保存',
				            icon:"<%=contextPath%>/images/save.gif",
				            handler:toCheck,
				            hidden:<%=(session.getAttribute("btn_savegzrwd_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN"))) ? false:true%>
				        },'-',
				        
				        {
				            text: '归档',
				            icon:"<%=contextPath%>/images/save.gif",
				            handler:toCheckHistory,
				            hidden:<%=( "1".equals(session.getAttribute("SESSION_ISADMIN"))) ? false:true%>
				        },'-',
				        {
				            text: '材料领用单',
				            icon:"<%=contextPath%>/images/pass.gif",
				            handler:ckd,
				            hidden:<%=session.getAttribute("btn_ckd_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>
				        },'-',
				        {
				            text: '打印',
				            icon:"<%=contextPath%>/images/print.png",
				            handler:function(){
				            	print();
				            },
				            hidden:<%=session.getAttribute("btn_print_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")) ? false:true%>
				        },'-',
				        {
				            text: '返回',
				            icon:"<%=contextPath%>/images/fanhui.png",
				            handler:function(){
				            	back();
				            }
				        }
			    	]
			    });
			});
		
			function toCheck(){
                if (document.getElementById("entity.id").value != "0"&&document.getElementById("entity.rq").value=="") {
		    		document.getElementById("entity.rq").datatype="";
					document.getElementById("entity.wcqk").min="0";
		    		document.getElementById("entity.ylwt").min="0";	
		           }
			  	if(!Validator.Validate(frmM,2)){
				  return false;
			  	}
				
  				comt();
		    }
		    function toCheckHistory(){

			  	if(!Validator.Validate(frmM,2)){
				  return false;
			  	}
				if (document.getElementById("entity.id").value != "0"&&document.getElementById("entity.rq").value=="") {
		    		document.getElementById("entity.rq").datatype="Require";
					document.getElementById("entity.wcqk").min="1";
		    		document.getElementById("entity.ylwt").min="1";	
					return false;
		           }
  				comthistory();
		    }
		    // 待办任务列表
		    function dbrw() {
		    
		    	if(!Validator.Validate(frmM,2)){
				  return false;
			  	}
		    
		    	var url = "<%=contextPath%>/gzrwd!getDbList.do";//"<%=contextPath%>/gzrwDbList!getList.do";
		    	var win = openSUB(url,1,1000,550,150,30);
		    }
// 未完成办任务列表
		    function wwcdbrw() {
		    
		    	if(!Validator.Validate(frmM,2)){
				  return false;
			  	}
		    
		    	var url = "<%=contextPath%>/gzrwDbList!getList.do?countPerPage=25";//"<%=contextPath%>/gzrwDbList!getList.do";
		    	var win = openSUB(url,1,1000,550,150,30);
		    }
		    function loadGzpno() {
				Ext.Ajax.request({
					method :'POST',
					url :'gzrwd!getGzpno.do?rq=${entity.rq}&bdzname=' + encodeURI('${entity.bdzname}'),
					success : function(response) {
						var users = Ext.decode(response.responseText);
        				var oSelect =  document.getElementById("gzpno");
						for(var i=0;i<users.length;i++) {
							var oOption = document.createElement("OPTION");
							oSelect.options.add(oOption);
							oOption.innerText = users[i]["itemname"];
							oOption.value = users[i]["itemid"];
						}
					},
					failure : function() {
						alert("链接变电运行系统失败");
					}
				});
	
			}
			 // 修改进入增加第二个环节的验证 by wangtao add20120525
		function setEndCheck() {
			//alert(document.getElementById("entity.rq").value);
		    if (document.getElementById("entity.id").value != "0"&&document.getElementById("entity.rq").value!="") {
		    		document.getElementById("entity.wcqk").min="1";
		    		document.getElementById("entity.ylwt").min="1";	
		    }
		   
		}
		 </script>  
	</head>
	<body onload="javascript:setEndCheck()">
		<div id = "tbar" style="position:absolute;display:block left:0px; top:0px; width:100%; height:35px; z-index:1;"></div>
	<br>
	<div id="Layer" style="position:absolute;display:block left:0px; top:35px; width:100%; height:94%; z-index:1000; overflow:auto;">
	
		<!-- 信息提示 -->
		<div id="result" align="center"><font color="red">${info }</font></div>
		<table width="100%" height="30">
			<tr>
				<td colspan="4" align="center">
					<font size="5"><b>变电检修工区工作任务单【无票】</b></font>
				</td>
			</tr>
		</table>
		
		<form id="frmM" name="frmM" method="POST" action="<%=contextPath%>/user!save.do">
			
			<input type="hidden" name="searchBean.con15" value="${entity.id}"/>
			<input type="hidden" name="ids" id="ids"/>
			<input type="hidden" name="fxgznr" id="fxgznr"/>
			<input type="hidden" name="idsalready" id="idsalready"/>
			<input type="hidden" id="hiddenids" name="hiddenids" value="${hiddenids}"/>			
			<s:hidden name="entity.id"  id="id_sno"/>
			<s:hidden name="entity.ouid"/>
			<s:hidden name="entity.bh"/>
			<s:hidden name="entity.zbz"/>
			<s:hidden name="entity.zby"/>
			<s:hidden name ="entity.dwry"/>	
			<s:hidden name ="entity.czr"/>	
			<s:hidden name ="entity.gzr"/>	
			<s:hidden name="entity.bdz"/>
			<s:hidden name="entity.state"/>
			<s:hidden name="bdz" />
			<s:hidden name="entity.planid" id="planid"/>	
			<table width="100%" height="30">
				<tr>
					<td colspan="4" align="right">
						<font color="red">*</font>&nbsp;编号：${entity.bh}
					</td>
				</tr>
			</table>	
			<table width="100%" id="infotab1">
			<tr>
					<th width="120" nowrap>
					<font color="red">*</font>&nbsp;开始时间：
					</th>
					<td>
						<input type="text" size="12" datatype="Require" onclick="WdatePicker({el:$dp.$('entity.czkssj')})" name="entity.czkssj" readonly="true" value='<fmt:formatDate value="${entity.czkssj}" pattern="yyyy-MM-dd HH:mm"/>' msg="开始时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.czkssj')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
					<th width="120" nowrap>
					<font color="red">*</font>&nbsp;结束时间：
					</th>
					<td>
						<input type="text"  size="12" datatype="Require" onclick="WdatePicker({el:$dp.$('entity.czjssj')})" name="entity.czjssj" readonly="true" value='<fmt:formatDate value="${entity.czjssj}" pattern="yyyy-MM-dd HH:mm"/>' msg="结束时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.czjssj')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
					<th width="120" nowrap>
						验收人：
					</th>
					<td>
						<input type="text" style="width:80" readonly="true" name="entity.czrname" value="${entity.czrname}" msg="验收人必须输入。"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('entity.czr','entity.czrname','entity.bdz')" />
					</td>
					<th width="120" nowrap>
						到位人员：
					</th>
					<td>
						
						<input type="text" style="width:80" readonly="true" name="entity.dwryname" value="${entity.dwryname}" msg="到位人员必须输入。"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('entity.dwry','entity.dwryname','entity.bdz')" />
						
					</td>
				</tr>
				<tr>
					
					<th width="120" nowrap>
						<font color="red">*</font>&nbsp;班组：
					</th>
					<td >
						<s:select list="bzList" datatype="Require" name="entity.bgzr" width="300" listKey="id" listValue="organName" emptyOption="true" msg="班组必须输入。"/>
					</td>
					<th width="120" nowrap>
						<font color="red">*</font>&nbsp;负责人：
					</th>
					<td >
					 <input type="text"  datatype="Require" readonly="true" style="width:80" name="entity.zbzname" value="${entity.zbzname}" msg="负责人必须输入。">
					<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUserselect('entity.zbz','entity.zbzname')" />
				
					</td>
					
					<th width="120" nowrap>
						<font color="red">*</font>&nbsp;成员:
					</th>
					<td >
						<input type="text"  datatype="Require" readonly="true" style="width:90%" name="entity.zbyname" value="${entity.zbyname}" msg="成员必须输入。">
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('entity.zby','entity.zbyname')" />
					</td>
				
					<th width="120" >
						<font color="red">*</font>&nbsp;每日工时：
					</th>
					<td><% if ((session.getAttribute("btn_gs_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")))) {%>
						<input type="text" style="width:50%" datatype="Number" maxlength="3" name="entity.gs" id="entity.gs" value = "${entity.gs}" msg="工时必须输入数字。"/>
						<%} else {%>
						<input type="text" style="width:50%" readonly="true"  datatype="Number" maxlength="3" name="entity.gs" id="entity.gs" value = "${entity.gs}" msg="工时必须输入数字。"/>

						<%}%>
					</td>
					
				</tr>
				
			
			<tr>
					<th width="120" >
						<font color="red">*</font>&nbsp;变电站：
					</th>
					<td nowrap>
							<!--<s:select list="bdzList" name="entity.bdzname" width="300" listKey="id" listValue="bdzname"/>-->
							<input type="text"  datatype="Require" readonly="true" style="width:80" name="entity.bdzname" value="${entity.bdzname}" msg="变电站必须输入。">
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getBdzjx('entity.bdz','entity.bdzname','entity.ouid')" />
					
					</td>
					
					<th width="120" nowrap>
						工作任务： 
					</th>
					<td nowrap colspan="5" >
						<textarea id="oc_gzfw" style="width:99%; height: 50px; min-height: 20px;line-height:15pt" datatype="LimitB" min="0"  max="2000" name="entity.ycclqk" msg="工作任务必须输入，最多输入1000个汉字。"/>${entity.ycclqk}</textarea>
					</td>
				</tr>
			
				<tr>
		                <th width="120" nowrap>
						&nbsp;<font color="red">*</font>&nbsp;车辆安排：</th>	
						<td>
						<% if ((session.getAttribute("btn_gs_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")))) {%>
						<input type="text" style="width:70%"   maxlength="25" name="entity.cxch" value="${entity.cxch}" msg="车辆安排必须输入。"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getCydy('CXCH','entity.cxch')" />
					<%} else {%>
					<input type="text" style="width:70%"  readonly="true" maxlength="25" name="entity.cxch" value="${entity.cxch}" msg="车辆安排必须输入。"/>	
					<%}%>
					</td>
					<th align="left" >同车班组：</th>
					<td colspan="1">
						<% if ((session.getAttribute("btn_gs_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")))) {%>
							<input type="text"  readonly="true" style="width:90%" name="entity.tcbz" value="${entity.tcbz}" msg="同车班组必须输入。">
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getBz('entity.gzr','entity.tcbz','entity.ouid')" />
					<%} else {%>
					<input type="text"  readonly="true" style="width:90%" name="entity.tcbz" value="${entity.tcbz}" msg="同车班组必须输入。">
						
					<%}%>
							</td>
							<th width="120" >
						<font color="red">*</font>&nbsp;外用工数：
					</th>
					<td><% if ((session.getAttribute("btn_gs_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")))) {%>
						<input type="text" style="width:50%" datatype="Number" maxlength="3" name="entity.wygs" id="entity.wygs" value = "${entity.wygs}" msg="外用工数必须输入数字。"/>
						<%} else {%>
						<input type="text" style="width:50%" readonly="true"  datatype="Number" maxlength="3" name="entity.wywgs" id="entity.wygs" value = "${entity.wygs}" msg="外用工数必须输入数字。"/>

						<%}%>
					</td>
				</tr>
				<tr>
					<th width="120" nowrap>
					<font color="red"></font>&nbsp;实际结束日期：
					</th>
					<td>
					<% if ((session.getAttribute("btn_sjrq_display") != null || "1".equals(session.getAttribute("SESSION_ISADMIN")))) {%>
						<input type="text"  size="9"  onclick="WdatePicker({dateFmt:'yyyy-MM-dd',el:$dp.$('entity.rq')})" name="entity.rq" readonly="true" value='<fmt:formatDate value="${entity.rq}" pattern="yyyy-MM-dd"/>' msg="实际结束日期必须输入。"/>
						<img onclick="WdatePicker({dateFmt:'yyyy-MM-dd',el:$dp.$('entity.rq')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
				<%} else {%>
						<input type="text" size="9" readonly="true" name="entity.rq" id="entity.rq" value='<fmt:formatDate value="${entity.rq}" pattern="yyyy-MM-dd"/>' />

						<%}%>
							</td>
					<th width="120" nowrap>
						&nbsp;<font color="red"></font>&nbsp;备注：</th>	
						<td nowrap colspan="5" >
						<textarea  style="width:99%; height: 50px; min-height: 20px;line-height:15pt" datatype="LimitB" min="0"  max="2000" name="entity.remark" />${entity.remark}</textarea>
					</td>
				</tr>
					<tr>
					<th width="120" nowrap>
					<font color="red"></font>&nbsp;完成情况：
					</th>
					<td nowrap colspan="7" >
						<textarea  style="width:99%; height: 50px; min-height: 20px;line-height:15pt" datatype="LimitB" min="0"  max="2000" name="entity.wcqk" msg="完成情况必须输入，最多输入1000个汉字。"/>${entity.wcqk}</textarea>
					</td>
					</tr>
					<tr>
					<th width="120" nowrap>
					<font color="red"></font>&nbsp;遗留问题：
					</th>
					<td nowrap colspan="7" >
						<textarea  style="width:99%; height: 50px; min-height: 20px;line-height:15pt" datatype="LimitB" min="0"  max="2000" name="entity.ylwt" msg="遗留问题必须输入，最多输入1000个汉字。"/>${entity.ylwt}</textarea>
					</td>
					</tr>
				<% if ("0".equals(session.getAttribute("SESSION_ISADMIN"))) {%>
				<tr>
					<th width="120" nowrap>
						录入人员：
					</th>
					<td>
						<s:hidden name="entity.cjrid"/>
						<input type="text" style="width:50%" readonly="true" name="entity.cjr" value="${entity.cjr}" msg="录入人员必须输入。"/>
					</td>
					<th width="120" nowrap>
						录入时间：
					</th>
					<td>
						<input type="text" name="entity.cjsj" readonly="true" value='<fmt:formatDate value="${entity.cjsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="巡视结束时间必须输入。"/>
					</td>
					<td colspan="4"></td>
				</tr>
				<%} else {%>
				<tr>
					<th width="120" nowrap>
						录入人员：
					</th>
					<td>
						<s:hidden name="entity.cjrid"/>
						<input type="text" style="width:50%" readonly="true" name="entity.cjr" value="${entity.cjr}" msg="录入人员必须输入。"/>
						<img style='cursor:pointer' src="<%=contextPath%>/images/editlink.gif" title="" onClick="javascript:getUser('entity.cjrid','entity.cjr','entity.bdz')" />
					</td>
					<th width="120" nowrap>
						录入时间：
					</th>
					<td>
						<input type="text" onclick="WdatePicker({el:$dp.$('entity.cjsj')})" name="entity.cjsj" readonly="true" value='<fmt:formatDate value="${entity.cjsj}" pattern="yyyy-MM-dd HH:mm"/>' msg="巡视结束时间必须输入。"/>
						<img onclick="WdatePicker({el:$dp.$('entity.cjsj')})" src="<%=contextPath%>/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle">
					</td>
					<td colspan="4"></td>
				</tr>
				<%}%>
			</table>
		</form>
		
		</div>
	</body>
</html>
<script language="javascript">

	String.prototype.startWith=function(str){
		if(str==null||str==""||this.length==0||str.length>this.length)
			return false;
		if(this.substr(0,str.length)==str)
			return true;
		else
			return false;
		return true;
	}
	
// 刷新
     function refresh(){
     	document.frmM.action = "<%=contextPath%>/gzrwdWp!initDetail.do?id=" + document.getElementById("entity.id").value;
		document.frmM.submit();
     }
	 // 保存
     function comt(){
     	//document.getElementById("entity.zbzname").value = document.getElementById("entity.zbz").options[document.getElementById("entity.zbz").selectedIndex].text;
     	document.frmM.action = "<%=contextPath%>/gzrwdWp!save.do";
     	document.frmM.submit();
     }
      // 归档
     function comthistory(){
     //	document.getElementById("entity.zbzname").value = document.getElementById("entity.zbz").options[document.getElementById("entity.zbz").selectedIndex].text;
     	document.frmM.action = "<%=contextPath%>/gzrwdWp!history.do";
     	document.frmM.submit();
     }
     // 通过任务单保存
     function saveRwd(ids) {
     	document.getElementById("entity.zbzname").value = document.getElementById("entity.zbz").options[document.getElementById("entity.zbz").selectedIndex].text;
     	document.getElementById("ids").value = ids;
        document.frmM.action = "<%=contextPath%>/gzrwd!saveRwd.do";
     	document.frmM.submit();
     }
     
     // 任务单选择是否时修改
     function updateRw(sfwc,czid,url,id) {
     
     	if (sfwc.options[sfwc.selectedIndex].value == "1") {
     	
     		var url2 = "<%=contextPath%>/" + url + "!initDetail.do?id=" + czid + "&gzrwdRwid=" + id + "&gzrwdry=" + document.getElementById("entity.zby").value;
     		
     		//url2 = encodeURI(url2);
			var win = window.open(url2,"Result_window2","left=50,top=30,width=1000,height=600,status=no,toolbar=no,autoscroll=yes,location=no,menubar=no,resizable=no",true);
		
		} else if (sfwc.options[sfwc.selectedIndex].value == "0") {
		
			Ext.MessageBox.show({   
                title:'工作任务未完成原因',   
                msg:'',   
                width:300,   
                buttons:Ext.MessageBox.OKCANCEL,   
                multiline:true,   
                fn:function(btn,text){   
                    
                    if (btn == "ok") {
                    
                    	var yc = "";
                    	if (document.getElementById("entity.ycclqk").value == "") {
                    		yc = text;
                    	} else {
                    		yc = document.getElementById("entity.ycclqk").value + "\n" + text;
                    	}
                    
						Ext.Ajax.request({
							method :'POST',
							url : "<%=contextPath%>/gzrwd!updateRw.do?id=" + id,
							params:{ycclqk:yc},
							success : function(response) {
								document.getElementById("entity.ycclqk").value = yc;
        						Ext.MessageBox.alert('提示','任务单已经取消');

							},
							failure : function() {
								alert("异步失败！");
								return false;
							}
						});
                    
                    } else {
                    	sfwc.options.selectedIndex = "0";
                    }
                    
                }   
            });   
            /*
            if (confirm("选定的任务确实没有完成吗？")) {
			
				var str = "";
				if (url == 'xsqk' && id == '0') {
					str = '&xslx=2'
				}
		
				Ext.Ajax.request({
					method :'POST',
					url : "<%=contextPath%>/gzrwd!updateRw.do?id=" + id + str,
					success : function(response) {
        				alert("任务单已经取消");

					},
					failure : function() {
						alert("异步失败！");
							return false;
					}
				});
			
			} else {
				sfwc.options.selectedIndex = "0";
			}
		*/
	
		}
     
     }
     
     // 风险点告知
     function fxdgz() {
		
		<c:if test="${GZRWDLIST == null || fn:length(GZRWDLIST) == 0 }">
			alert("请先添加工作任务");
			return;
		</c:if>
		
    	var t = document.getElementById("TGzrwdFxgz");
    		
    	var idsalready = "";
    		
       	for (var i=0;i<t.childNodes.length;i++) {
       		idsalready += "," + t.childNodes[i].childNodes[0].innerHTML;
       	}

		if (idsalready.startWith(",")) {
			idsalready = idsalready.substring(1,idsalready.length);
		}
		
		document.getElementById("idsalready").value = idsalready;

 		var url = "<%=contextPath%>/jsp/popup/fxgzCheckBox.jsp?";
 		window.open(url,"变电检修工区工作任务单","left=500,top=30,width=320,height=600,status=no,toolbar=no,autoscroll=yes,location=no,menubar=no,resizable=no",true);
		//var win = openSUB(url,2,500,600,500,30);
     
     }
     
     // 任务风险告知保存
     function saveFxgz(ids) {
     	document.getElementById("entity.zbzname").value =  document.getElementById("entity.zbz").options[document.getElementById("entity.zbz").options.selectedIndex].text;
     	document.getElementById("ids").value = ids;
        document.frmM.action = "<%=contextPath%>/gzrwd!saveFxgz.do";
     	document.frmM.submit();
     }
     // 任务风险告知修改
     function updateFxgz(ids,fxgznr) {
     	document.getElementById("entity.zbzname").value =  document.getElementById("entity.zbz").options[document.getElementById("entity.zbz").options.selectedIndex].text;
     	document.getElementById("ids").value = ids;
     	//window.alert(ids+"----"+fxgznr);
     	//window.alert(document.getElementById(fxgznr).value);
     	document.getElementById('fxgznr').value = document.getElementById(fxgznr).value;
        document.frmM.action = "<%=contextPath%>/gzrwd!updateFxgz.do";
     	document.frmM.submit();
     }
	// 删除文件
    function deleteDetail(id,model,trid){
    
    	var msg = "确定要删除吗？";

		if (trid.startWith("gzrw")) {
			msg = "确定要取消工作任务吗？";
		}    
    	if (confirm(msg)) {
    	
				Ext.Ajax.request( {
					method :'POST',
					url :'gzrwd!deleteDetail.do?id='+ id+"&model=" + model,
					success : function(response) {
        				var mytable = document.getElementById(model);  
        				var myrow = document.getElementById(trid);   
       				    mytable.deleteRow(myrow.rowIndex-1);  
       				    
       				    Ext.MessageBox.alert('提示','取消成功');
						
					},
					failure : function() {
						Ext.MessageBox.alert('提示','取消失败');
					}
				});
		}
    }
     
     // 返回
     function back() {
     	document.frmM.action = "<%=contextPath%>/gzrwdList!getList.do?planid=" + document.getElementById("entity.planid").value;
		document.frmM.submit();
     }
     
     // 打印
     function print() {
     	
     	if (document.getElementById("entity.id").value == "0") {
     		alert("请先保存信息");
     		return;
     	}
 		var url = "<%=contextPath%>/gzrwd!print.do?id=" + document.getElementById("entity.id").value;
 		//window.open(url,"变电运行工区工作任务单","left=50,top=30,width=1000,height=600,status=no,toolbar=no,autoscroll=yes,location=no,menubar=no,resizable=no",true);
		var win = openSUB(url,2,800,600,50,30);
     }
  // 待办任务单删除
     function deleteRwd(ids) {
     	document.getElementById("entity.zbzname").value = document.getElementById("entity.zbz").options[document.getElementById("entity.zbz").selectedIndex].text;
     	document.getElementById("ids").value = ids;
        document.frmM.action = "<%=contextPath%>/gzrwd!deleteRwd.do";
     	document.frmM.submit();
     }
     
</script>
<script language="javascript">
		
     
  /**   // 返回
     function back() {
     	document.frmM.action = "<%=contextPath%>/listRwd!getList.do";
		document.frmM.submit();
     }*/
	 
	 // 增加行
	 function setHTML() {
	 
	 	var temp = "WdatePicker({dateFmt:'yyyy-MM-dd',el:$dp.$('listRwd[" + usernum + "].plandate')})";

		var str = 	'<tr id = '+ usernum +' class = "repeat">' +
					'<td width="30"><img src="/DLPLANMIS/images/delete.gif" onclick = "delrow(this,0)" style="cursor:pointer"/></td>' + 
					'<td width="30">'+usernum+'</td>' + 
					'<td width="100%"><textarea style="width:100%; height: 25px; min-height: 20px;line-height:15pt"  id=listRwd['+ usernum + '].rwnr name=listRwd['+ usernum + '].rwnr ></textarea></td >' +
					'<td width="100"></td>' + 

					'<input type="hidden" id=listRwd['+ usernum + '].id name=listRwd['+ usernum + '].id value ="0">' +
					'</tr>';
					
		$('table.leadertab').append(str);	
				
		usernum++;
		
		// 重新付序号
//		var n = 0;		
//		for (var index=0;index<usernum; index++) {
//			if (document.getElementById("td" + index) != null && document.getElementById("td" + index) != undefined) {
//				++n;
//				document.getElementById("td" + index).innerHTML = n;
//			}
//		}				
//	 }

		$('textarea').autogrow();	
	
	}
	
	//删除一行（已有数据）
	function delrow(row,id){


		if (confirm("确定要删除该工作任务吗？")) {
			if(id != 0) {
				Ext.Ajax.request({
					method :'POST',
					url :'gzrwd!deleteRwdDetail.do?id=' + id,
					params : {},
					success : function(response, options) {
						var obj = Ext.decode(response.responseText);
						Ext.MessageBox.alert('提示', obj["msg"]);
					
	   					$(row).parents(".repeat").remove();	

					},
					failure : function(response, options) {
						Ext.MessageBox.alert('提示 ', '删除失败。');
					}
				});
			} else {
				$(row).parents(".repeat").remove();	
			}

		}

	} 
	//记录回填
     function jlhuitian(bzlb){
     	var url = "<%=contextPath%>/gzjl!toDetail.do?gzrwd.id=" + document.getElementById("entity.id").value + "&entity.bzlb=" + bzlb;
     	var win = openSUB(url,2,800,600,50,30);
     }

	function Trim(str) {
	return LTrim(RTrim(str));
	}

	function LTrim(str) {
		if (str)
			return str.replace(/(^\s*)/g, "");
		else
			return "";
	}

	function RTrim(str) {
		if (str)
			return str.replace(/(\s*$)/g, "");
		else
			return "";
	}
	function getSelectText(id){
	var obj_sele=document.getElementById(id);
	for(var i=0;i<obj_sele.length;i++){
	if(obj_sele[i].selected==true){	
	return obj_sele[i].text;
	break;
	}
	}	
	return '';	
	}
    
	 //班组作业控制卡
     function openBZZYKZK(){
	 var var_gzpno= document.getElementById("id_gzpno").value;	
	 var var_gzfw=document.getElementById("oc_gzfw").value;
	 var planid=document.getElementById("planid").value;
	 var var_idsno=document.getElementById("id_sno").value;
	 //有工作范围的是一种票，无工作范围的是二种票
	 if(Trim(var_gzfw)!=""&&Trim(var_idsno)!=""){
		 if(Trim(planid)!=""){//工作计划id不为空，则为修改一票
		  if(var_idsno==0) {
		 			alert("请先保存工作任务单再起草控制卡");
		 		return false;
		 	}
		 parent.addTab("班组作业控制卡（一种票）", "<%=contextPath%>/workcardOne!skipByPlanid.do?entity.pno="+var_gzpno+"&entity.planid="+planid);
		 }
	 }else if(Trim(var_gzfw)==""&&Trim(var_idsno)!=""){//二种票	 
		 if(planid!=""){//作业控制卡二票id不为空，则为修改二票
		  if(var_idsno==0) {
		 			alert("请先保存工作任务单再起草控制卡");
		 		return false;
		 	}
		 parent.addTab("班组作业控制卡（二种票）", "<%=contextPath%>/workcardTwo!skipByPlanid.do?entity.planid="+planid+"&id="+var_idsno);
		 }else{//作业控制卡二票id为空，则为新建二票
		 if(var_idsno==0) {
		 			alert("请先保存工作任务单再起草控制卡");
		 		return false;
		 	}
		 parent.addTab("班组作业控制卡（二种票）", "<%=contextPath%>/workcardTwo!initPage.do?id="+var_idsno);
		  //新建时控制卡中要求工作任务单中保存控制卡的id
		 }	 
	 }
	 else{
	 alert("请先保存工作任务单之后再打开班组作业控制卡！");
	 }
	 }
	  //工序质量控制卡
	  function openGXZLKZK(){
	var var_idsno=document.getElementById("id_sno").value;
	var planid=document.getElementById("planid").value;
	 if(Trim(var_idsno)!=""){
	  if(var_idsno==0) {
		 			alert("请先保存工作任务单再起草控制卡");
		 		return false;
		 	}
	 parent.addTab("工序质量控制卡", "<%=contextPath%>/gxzlkzk!skipByPlanid.do?id="+var_idsno+"&entity.planid="+planid);
	 }
	}
	function getGzpnose(obj){
	
		document.getElementById("id_gzpno").value=obj.value;
		}
		// 起草工作任务单任务
		function toNewRwd(paramBzid,paramPlanid,paramBdzid,paramBzlength,paramGzrwdid){
		  var url = "<%=contextPath%>/jsp/business/gzrwd/bzgzrw.jsp?paramBzid="+paramBzid+"&paramPlanid="+paramPlanid+"&paramBdzid="+paramBdzid+"&paramBzlength="+paramBzlength+"&paramGzrwdid="+paramGzrwdid;
		 var win = window.open(url,"工作任务单任务新建选择","left=150,top=30,width=1284,height=768,status=no,toolbar=no,autoscroll=yes,location=no,menubar=no,resizable=yes",true);
	
				}
				//材料领用单
	  function ckd(){
	var var_idsno=document.getElementById("id_sno").value;
	var planid=document.getElementById("planid").value;
	 if(Trim(var_idsno)!=""){
	  if(var_idsno==0) {
		 		alert("请先保存工作任务单再起草材料领用单");
		 		return false;
		 	}
	 parent.addTab("材料领用单", "<%=contextPath%>/cllyjl!initCllyjlDetail.do?gzrwdid="+var_idsno);
	 }
	}
</script>